﻿#include <iostream>
#include <algorithm>

using namespace std;
string s;
int main() {
    cout << "请输入一个含大写的字符串：";
    string str;
    cin >> str;
    ///转小写
    transform(str.begin(), str.end(), str.begin(), ::tolower);
    cout << "转化为小写后为：" << str << endl;
    transform(str.begin(), str.end(), str.begin(), ::toupper);
    cout << "转化为大写后为：" << str << endl;
    return 0;
}

#include <iostream>
#include <map>
#include <vector>
#include <string>
#include<algorithm>
using namespace std;


vector<string> SplitString(string& str)
{
    vector<string> ret;
    string word = "";
    for (auto e : str)
    {
        if (e == ' ')
        {
            ret.push_back(word);
            word = "";
        }
        else
        {
            if (e != '.')
                word = word + e;
        }

    }

    ret.push_back(word);
    return ret;
}



//int main()
//{
//    string str("A blockhouse is a small castle that has four openings through which to shoot.");
//    vector<string> s = SplitString(str);
//    map<string, int> countmap;
//    int i = 0;
//    for (auto h : s)
//    {
//        transform(s[i].begin(), s[i].end(), s[i].begin(), ::tolower);
//        i++;
//    }
//    for (auto e : s)
//    {
//        countmap[e]++;
//    }
//
//    for(auto w:countmap)
//    {
//        cout << w.first << ":" << w.second << endl;
//    }
//     return 0;
//}

//a:2
//blockhouse : 1
//castle : 1
//four : 1
//has : 1
//is : 1
//openings : 1
//shoot : 1
//small : 1
//that : 1
//through : 1
//to : 1
//which : 1


int longestOnes1(vector<int>& nums, int k)
{
    int ret = 0;
    for (int left = 0, right = 0, zero = 0; right < nums.size(); right++)
    {
        if (nums[right] == 0) zero++; // 进窗⼝
        while (zero > k) // 判断
            if (nums[left++] == 0) zero--; // 出窗⼝
        ret = max(ret, right - left + 1); // 更新结果
    }
    return ret;

}
int longestOnes(vector<int>& nums, int k)
{
    int left = 0, right = 0;
    int len = 0;
    int sz = nums.size();
    int zero = 0;
    while (right < sz)
    {
        if (nums[right] == 0)
        {
            zero++;
        }
        while (zero > k)
        {
            if (nums[left] == 0)
            {
                zero--;
            }
            left++;
        }
        len = max(len, right - left + 1);
        right++;
    }

    return len;
}



//int main()
//{
//    vector<int> v{ 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0 };
//    int k = 2;
//    int ret = longestOnes(v, k);
//    cout << ret << endl;
//
//    return 0;
//}